/*
 * 输出器，支持标准输出，html格式输出，csv格式输出
 *
 */

#ifndef  __OUTPUT_H__
#define  __OUTPUT_H__


#include <map>
#include <string>
#include <ostream>

#include "common.h"
#include "sum.h"

using namespace std;

//标准输出
class Output
{
public:
	Output(const int field_num, const string outfile = "");
	Output(const Output &op);
	Output& operator=(const Output &op);

	void FlushData2Stream(const DataSum &ds);
protected:
	const int KeyWidth(const int len) const;
	const double CalcValue(const CALC_TYPE ct, const result_t &res) const;
	//virtual void DoIt(ostream &os, const map<string, result_t*> &mp);
	virtual void DoIt(ostream &os, const DataSum &ds);
protected:
	int	m_nFieldNum;
	string	m_strOutFile;
};


class HTMLOutput : public Output
{
public:
	HTMLOutput(const int field_num, const string outfile = "");
	HTMLOutput(const HTMLOutput &op);
	HTMLOutput& operator=(const HTMLOutput &op);

protected:
	//virtual void DoIt(ostream &os, const map<string, result_t*> &mp);
	virtual void DoIt(ostream &os, const DataSum &ds);
};


class CSVOutput : public Output
{
public:
	CSVOutput(const int field_num, const string outfile = "");
	CSVOutput(const CSVOutput &op);
	CSVOutput& operator=(const CSVOutput &op);

protected:
	//virtual void DoIt(ostream &os, const map<string, result_t*> &mp);
	virtual void DoIt(ostream &os, const DataSum &ds);
};


#endif

